package com.ghca.myinfo.market.controllers;

import com.alibaba.fastjson.JSONObject;
import com.ghca.myinfo.common.EasuUIPageRequest;
import com.ghca.myinfo.market.entities.TenderNotice;
import com.ghca.myinfo.market.services.TenderNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2017/2/2.
 */
@Controller
@RequestMapping("/market/tendernotice")
public class TenderNoticeController {

    @Autowired
    private TenderNoticeService tenderNoticeService;

    @RequestMapping
    public String tendernotice() {
        return "market/tendernotice";
    }

    @RequestMapping("/list")
    @ResponseBody
    public EasuUIPageRequest<TenderNotice> list(TenderNotice example, Pageable pageable) {
        Page<TenderNotice> list = tenderNoticeService.list(example, new PageRequest(pageable.getPageNumber()-1,pageable.getPageSize(), Sort.Direction.DESC, "startDate"));
        return new EasuUIPageRequest<TenderNotice>(list);
    }

}
